﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Server_Monitor.Controllers;
using Server_Monitor.Domain;

namespace Server_Monitor.Forms
{
    public partial class Servers : Form
    {
        public Servers()
        {
            InitializeComponent();
        }

        private void Servers_FormClosed(object sender, FormClosedEventArgs e)
        {
            this.Dispose();
        }

        private void btnAdd_Click(object sender, EventArgs e)
        {
            ServerController.AddServers(new Server { ServerIP = txtIP.Text.Trim(), ServerName = txtServerName.Text.Trim() });
            ServerController.SaveServers();
            RefreshServerGrid();
        }

        private void Servers_Load(object sender, EventArgs e)
        {
            RefreshServerGrid();
        }
        private void RefreshServerGrid()
        {
            dgServers.DataSource = null;
            dgServers.DataSource = ServerController.GetServers();
        }

        private void dgServers_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
        {
        }
    }
}
